function prim(matrix, p) {
    
}


let m = [
    [0, 2, 4, 1, Infinity, Infinity, Infinity],
    [2, 0, Infinity, 3, 10, Infinity, Infinity],
    [4, Infinity, 0, 2, Infinity, 5, Infinity],
    [1, 3, 2, 0, 7, 8, 4],
    [Infinity, 10, Infinity, 7, 0, Infinity, 6],
    [Infinity, Infinity, 5, 8, Infinity, 0, 1]
    [Infinity, Infinity, Infinity, 4, 6, 1, 0]
]

prim(m, 0)